import kafka

print(kafka.__version__)
from kafka import KafkaProducer, KafkaConsumer

KAFKA_URL = '192.168.0.195:9092'  # kafka broker
KAFKA_TOPIC = 'test-kafka'  # topic name

# producer = KafkaProducer(bootstrap_servers=[KAFKA_URL])
# for i in range(3):
#     producer.send(KAFKA_TOPIC, ('msg' + str(i)).encode())
# producer.flush()

consumer = KafkaConsumer(KAFKA_TOPIC,
                         bootstrap_servers=[KAFKA_URL],
                         max_poll_records=2,
                         auto_offset_reset='earliest',
                         group_id="t1",
                         )
for msg in consumer:
    print(msg.value.decode('utf-8'))
